package io.chenglicun.common.utils;

import io.chenglicun.modules.sys.service.SysParamsService;

public class SysParamsUtils {

    private static SysParamsService sysParamsService;

    static {
        SysParamsUtils.sysParamsService = SpringContextUtils.getBean(SysParamsService.class);
    }

    public static int getInt(String key) {
        String value = sysParamsService.getValue(key);
        return Integer.parseInt(value);
    }

    public static long getLong(String key) {
        String value = sysParamsService.getValue(key);
        return Long.parseLong(value);
    }

    public static boolean getBool(String key) {
        String value = sysParamsService.getValue(key);
        return Boolean.parseBoolean(value);
    }

    public static String getString(String key) {
        return sysParamsService.getValue(key);
    }

    public static <T> T getObj(String key, Class<T> clazz) {
        return sysParamsService.getValueObject(key, clazz);
    }

}
